// Copyright (c) 2025 Huawei Technologies Co., Ltd.
// openUBMC is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//         http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
//
// Description: 封装不同类型的数据报文

#include "PackData.hpp"

PackData::PackData() = default;

PackData::~PackData() = default;

std::vector<uint8_t> PackData::ConnectKvm(const std::string& token) {
    std::vector<uint8_t> body(token.begin(), token.end());
    return kvmMsg_.Pack(CMD_CONNECT_REQ_C, 0, body);
}

std::vector<uint8_t> PackData::DisconnectKvm() {
    return kvmMsg_.Pack(CMD_DISCONNECT_REQ_C, 0, std::vector<uint8_t>());
}

std::vector<uint8_t> PackData::KvmHeartBeat() {
    return kvmMsg_.Pack(CMD_HEARTBEAT_REQ_C, 0, std::vector<uint8_t>());
}

std::vector<uint8_t> PackData::GetBootOption() {
    return kvmMsg_.Pack(CMD_GET_BOOT_OPTION_REQ_C, 0, std::vector<uint8_t>());
}

std::vector<uint8_t> PackData::SetBootOption(std::vector<uint8_t> body) {
    return kvmMsg_.Pack(CMD_SET_BOOT_OPTION_REQ_C, 0, body);
}

std::vector<uint8_t> PackData::PowerControl(std::vector<uint8_t> body) {
    return kvmMsg_.Pack(CMD_POWER_CONTROL_REQ_C, 0, body);
}

std::vector<uint8_t> PackData::GetVmmStatus() {
    return kvmMsg_.Pack(CMD_GET_VMM_STATUS_REQ_C, 0, std::vector<uint8_t>());
}

std::vector<uint8_t> PackData::GetVmmPort() {
    return kvmMsg_.Pack(CMD_GET_VMM_PORT_REQ_C, 0, std::vector<uint8_t>());
}

std::vector<uint8_t> PackData::ConnectVmm(const std::string& token) {
    std::vector<uint8_t> body(token.begin(), token.end());
    return vmmMsg_.Pack(VMM_OPCODE::CONNECT, body, 0, 0, 0);
}

std::vector<uint8_t> PackData::DisconnectVmm() {
    return vmmMsg_.Pack(VMM_OPCODE::DISCONNECT, {}, 0, 0, 0);
}

std::vector<uint8_t> PackData::VmmHeartBeat() {
    return vmmMsg_.Pack(VMM_OPCODE::HEARTBEAT, {}, 0, 0, 0);
}

std::vector<uint8_t> PackData::CreateDevice(uint8_t deviceType) {
    return vmmMsg_.Pack(VMM_OPCODE::CREATE_DEV, {deviceType}, 0, 0, 0);
}

std::vector<uint8_t> PackData::CloseDevice(uint8_t deviceType) {
    return vmmMsg_.Pack(VMM_OPCODE::CLOSE_DEV, {deviceType}, 0, 0, 0);
}

std::vector<uint8_t> PackData::SffOperationEnd(uint8_t result, uint8_t id) {
    return vmmMsg_.Pack(VMM_OPCODE::SFF_OPT_END, {}, result, 0, id);
}

std::vector<uint8_t> PackData::SffDataPack(uint8_t dataType, uint8_t state, uint32_t dataLength, uint8_t seq) {
    return vmmMsg_.SffDataPack(dataType, state, dataLength, seq);
}
